module.exports = {
  up: function(migration, DataTypes, done) {
    // add altering commands here, calling 'done' when finished

    migration.createTable('groups',
      {
        id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
        owner_id:    { type:DataTypes.INTEGER  },
        title:       { type:  DataTypes.STRING },
        createdAt:   { type: DataTypes.DATE    },
        updatedAt:   { type: DataTypes.DATE    },
      },
      {
        engine: 'InnoDB', // default: 'InnoDB'
      }
    )

    migration.createTable('group_members',
    {
      id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
      user_id:     { type:DataTypes.INTEGER  },
      group_id:     { type:DataTypes.INTEGER  },
    })

    done()
  },
  down: function(migration, DataTypes, done) {
    // add reverting commands here, calling 'done' when finished
    migration.dropTable('groups')
    done()
  }
}
